<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="gb2312"><!--用于http传输-->
    <title>新闻详情</title>
    <link rel="stylesheet"  href="http://libs.baidu.com/bootstrap/2.3.2/css/bootstrap.css">
</head>
<body onload="addHistory()">

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="text-center">
                推荐系统
            </h3>
        </div>
    </div>
        <div class="row-fluid" align="right">
            <div class="span6" style="right: 100px">
                <a href="/User/Login" th:if="${session.loginUser}==null">登录</a>
                <a id="user" th:if="${session.loginUser}" th:text="${session.loginUser.username}" ></a>
                <a th:if="${session.loginUser}" href="/User/logout"}>退出登陆</a>
            </div>

        </div>

    <div class="row-fluid" style="left: 250px;position: absolute">

        <div class="span6" style="left: 100px;">
            <p>
                首页 >> 新闻
            </p>
            <h3 th:text="'新闻标题:'+${oneById.title}">
            </h3>
            <p th:text="'id:'+${oneById.id}" id="article_id">

            </p>
            <p th:text="'url:'+${oneById.url}">

            </p>
            <p th:text="'正文内容:'+${oneById.content.content}">
            </p>
        </div>
        <div class="span4">
            <h3>
                相关新闻
            </h3>
            <ul th:each="correlateList:${correlateList}">
                <a th:href="@{'/ContentView/getOne?id='+${correlateList.id}}"><li th:text="${correlateList.title}"/></a>
            </ul>
        </div>
    </div>
    <div class="row-fluid">
        <div>评分</div>
        <div class="span12">
            <select id="point" name="view" style="width: 50px">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
            </select>
            <button onclick="func()">提交</button>
        </div>
    </div>

</div>
<script>
    function func() {
        var point = document.getElementById("point");
        var article_id = document.getElementById("article_id").innerText.substring(3);
        var index = point.selectedIndex;
        window.location.href = "/view/submit?interest="+point.options[index].value+"&article_id="+article_id;
    }
    function addHistory(){
        var article_id = document.getElementById("article_id").innerText.substring(3);

        var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象
        httpRequest.open('GET', 'http://localhost/ContentView/logView?article_id='+article_id, true);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
        httpRequest.send();//第三步：发送请求  将请求参数写在URL中
        httpRequest.onreadystatechange = function () {
            if (httpRequest.readyState == 4 && httpRequest.status == 200) {
                var json = httpRequest.responseText;//获取到json字符串，还需解析
                console.log(json);
            }
        };

    }
</script>
</body>
</html>